﻿
@{
	ViewBag.Title = "ApplicationApply";
	Layout = "~/Views/Shared/_Index.cshtml";
	var opr = Newtouch.Common.Operator.OperatorProvider.GetCurrent();
}

<form name="form1">
	<div class="panel panel-default">
		<table class="form">
			<tr>
				<th class="formTitle" id="thCZRQ">结算日期：</th>
				<td class="formValue" colspan="2">
					<input id="ksrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:20%; float:left;" value="@DateTime.Now.ToString("yyyy-MM-01")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
					<span style="margin-left:2%;float:left;">—</span>
					<input id="jsrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width :20%;float:left;margin-left:2%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />

					<text style="margin-left:2%">是否异地：</text>
					<text></text>
					<input type="radio" name="sfyd" value="否" checked />
					<label>本地</label>
					<input type="radio" name="sfyd" value="是" />
					<label>异地</label>
					<input type="button" id="btn_tj" class="btn btn-primary btn-md" style="margin-right:10px;width:40px;" value="统计" />
					<input type="button" id="btn_sq" class="btn btn-primary btn-md" style="margin-right:10px;width:40px;" value="申请" />
					@*<input type="button" id="btn_gb" class="btn btn-primary btn-md" style="margin-right:10px;width:80px;" value="申请撤销" />*@
				</td>
				<td class="formValue"></td>
			</tr>
		</table>
	</div>



	<div style="background-color: #fff;">
		<table id="gridJSList"></table>
	</div>
	<div style="background-color: #fff; margin-top:5px;">
		<table id="gridJSMXList"></table>
	</div>
	<div class="gridPanel">
		<table id="gridJSList"></table>
		<div id="gridPager"></div>
	</div>



	@* 底部表格 *@
	<div style="background-color: #fff;">
		<table id="gridJSList1"></table>
	</div>
	<div style="background-color: #fff; margin-top:5px;">
		<table id="gridJSMXList1"></table>
	</div>
	<div class="gridPanel">
		<table id="gridJSList1"></table>
		<div id="gridPager1"></div>
	</div>



</form>


<script>
    $(function () {
        //浏览器窗口调整大小时重新加载jqGrid的宽
        $(window).resize(function () {
            initLayout("MyTabGrid");
        });

        gridJSListData();

    });

    function gridJSListData() {
        var gridSort = 'CreateTime asc';
        var $gridJsList = $("#gridJSList");
        $gridJsList.dataGrid({
            //postData: getSearchPostData(),
            height: 500,
            url: "",
            colModel: [
				{
					label: '申请状态', name: 'sqzt', width: 100, align: 'left', formatter: function (val, a, b) {
						if (val == "1") {
							return "已申请"
						} else {
							return "未申请"
						}
					} },
				{ label: '清算类别', name: 'qslb', hidden: true, align: 'left' },
				{ label: '清算类别', name: 'qslbmc', width: 100, align: 'left' },
                { label: '险种类型', name: 'xzlx', width: 100, align: 'left' },
                { label: '是否异地', name: 'sfyd', width: 100, align: 'left' },
				{ label: '开始日期', name: 'ksrq', width: 100, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
				{ label: '结束日期', name: 'jsrq', width: 100, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
                { label: '总费用', name: 'zfy', width: 100, align: 'left' },
                { label: '基金支付总额', name: 'jjzfze', width: 100, align: 'left' },
                { label: '个账支付', name: 'gzzf', width: 100, align: 'left' },
                { label: '医保认可费用总额', name: 'ybrkfyze', width: 100, align: 'left' },
                { label: '现金支付总额', name: 'xjzfze', width: 100, align: 'left' },
                { label: '清算人次', name: 'qsrc', width: 100, align: 'left' },
                { label: '清算年月', name: 'qsny', width: 100, align: 'left' },
                { label: '门诊申报金额', name: 'mzsbje', width: 100, align: 'left' },
                { label: '住院申报金额', name: 'zysbje', width: 100, align: 'left' },
				{ label: '城镇职工基本医疗保险统筹基金', name: 'czzgtcjj', width: 100, align: 'left' },
				{ label: '城镇职工基本医疗保险个人账户基金', name: 'czzgzhjj', width: 100, align: 'left' },
				{ label: '公务员医疗补助基金', name: 'gywbzjj', width: 100, align: 'left' },
				{ label: '大额医疗费用补助基金', name: 'deylbzjj', width: 100, align: 'left' },
				{ label: '离休人员医疗保障基金', name: 'lxrybzjj', width: 100, align: 'left' },
				{ label: '一至六级残疾军人医疗补助基金', name: 'cjbzjj', width: 100, align: 'left' },
				{ label: '企业补充医疗保险基金', name: 'qybzyljj', width: 100, align: 'left' },
				{ label: '城乡居民基本医疗保险基金', name: 'cxjmjbyljj', width: 100, align: 'left' },
				{ label: '城乡居民大病医疗保险基金', name: 'cxjmdbyljj', width: 100, align: 'left' },
				{ label: '医疗救助基金', name: 'yljzjj', width: 100, align: 'left' },
            ],
            //pager: "#gridPager",
            //sortname: gridSort,
			viewrecords: true,
			footerrow: true,
			userDataOnFooter: true,
			loadComplete: function () {

				var gridData = $("#gridJSList").jqGrid('getGridParam', 'data');

				$("#gridJSList").jqGrid('footerData', 'set', { name: "count", count: gridData.length });

			},
            onSelectRow_page: function (rowid) {
                //console.log(rowid);
            },
            gridComplete: function (gridJszbList) {
                //jszbList = null;
                //if (gridJszbList && gridJszbList.rows) {
                //    jszbList = gridJszbList.rows;
                //}
            }
        });

        //查询事件
        $("#btn_tj").click(function () {
			$('#gridJSList').jqGrid("clearGridData");//先清空明细
            $gridJsList.jqGrid('setGridParam', {
				postData: { ksrq: $("#ksrq").val(), jsrq: $("#jsrq").val(), sfyd: $('input:radio[name="sfyd"]:checked').val() },
                url: '/MedicalInsuranceLiquidation/LiquidationApplication/GetQssq',
                //page: 1,
            }).trigger('reloadGrid');
        });
	}

	$("#btn_sq").click(function () {

		var seleRowid = $("#gridJSList").jqGrid("getGridParam", "selrow");
		if (!(seleRowid)) {
			$.modalAlert("请选中一条信息", 'warning');
			return;
		}

		var rowData = $("#gridJSList").jqGrid('getRowData', seleRowid);
		var ksrq = $("#ksrq").val();
		var jsrq = $("#jsrq").val();

		var predata = {
			hisId: "0",
			operatorId: '@(opr.rygh)',
			operatorName:'@(opr.UserName)',
			clr_type: rowData.qslb,
			clr_way: "",
			setlym: rowData.qsny,
			psntime: rowData.qsrc,
			medfee_sumamt: rowData.zfy,
			med_sumfee: rowData.ybrkfyze,
			fund_appy_sum: rowData.jjzfze,
			cash_payamt: rowData.xjzfze,
			acct_pay: rowData.gzzf,
			begndate: ksrq,
			enddate: jsrq,
			sfyd: rowData.sfyd
		};

		$.ajax({
			type: "POST",
			url: "http://127.0.0.1:33333/api/YiBao/ReconciliationDetail_3203",
			data: predata,
			dataType: "json",
			async: false,
			success: function (data) {
				var refinfo = eval('(' + data + ')');
				console.log(refinfo);
				if (refinfo.infcode == "0") {
					$.modalAlert("提交清算成功！", 'warning');
					$("#btn_tj").click();
				} else {
					$.modalAlert(refinfo.err_msg,'warning');
				}

			}
		});
	});



</script>